package app.controller.order;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import app.model.order.OrderRecord;
import app.service.order.OrderRecordService;
import base.JsonResult;
import base.PageInfo;

@Controller
@RequestMapping("/order")
public class OrderRecordController {
	
	private Logger logger = Logger.getLogger(OrderRecordController.class);
	
	@Autowired
	private OrderRecordService orderRecordService;
	
	@ResponseBody
	@RequestMapping("/query.do")
	public PageInfo query(PageInfo pageInfo,String orderNo,String orderStatus){
		return orderRecordService.queryByPage(pageInfo,orderNo,orderStatus);
	}
	
	@ResponseBody
	@RequestMapping("/save.do")
	public JsonResult save(OrderRecord orderRecord){
		if(StringUtils.isEmpty(orderRecord.getId())){
			orderRecordService.saveEntity(orderRecord);
		}else{
			orderRecordService.updateEntity(orderRecord);
		}
		return new JsonResult("操作成功");
	}
	
	@ResponseBody
	@RequestMapping("/view.do")
	public JsonResult view(String id){
		Map<String, Object> orderRecord = orderRecordService.queryEntityById(id);
		return new JsonResult("操作成功",orderRecord);
	}
	
	@ResponseBody
	@RequestMapping("/del.do")
	public JsonResult del(String ids){
		orderRecordService.delEntity(ids);
		return new JsonResult("操作成功");
	}
}
